<?php
include ("global.php");

if($configarray[40]){
	$links=" > Profile";
	$pagetitle=" - Profile";
	include("header.php");
	$tplcontent['notice']="<b>Board closed:</b><br>$configarray[40]";
	echo template('notice',$tplcontent);
}else{
	
	$userarray=getdata("$configarray[1]/$user/main.php");
	
	//not logged in/no such user
	if(count($userarray)<=0){
		$links=" > Profile";
		$pagetitle=" - Profile";
		
		include("header.php");
		
		$tplcontent['notice']="Please specify a user that exists!";
		echo template('notice',$tplcontent);
		
	}else{
		
		$links=" > Profile: $userarray[0]";
		$pagetitle=" - Profile: $userarray[0]";
		
		include("header.php");
		
		
		$tplcontent['user']="$user";
		
		$emailarray=explode("\t",$userarray[2]);
		if($emailarray[1]=="hide"){
			$tplcontent['email']="Hidden";
		}else{
			$tplcontent['email']="$emailarray[0]";
		}
		
		$date=date($dateformat,$userarray[4]+$timeoffsetseconds);
		$tplcontent['registered']=$date;
		
		$lastseenarray=explode("\t",$userarray[5]);
		$date=date($dateformat,$lastseenarray[1]+$timeoffsetseconds);
		$tplcontent['lastseen']=$date;
		
		$tplcontent['postcount']=$userarray[6];
		
		$birthday=explode("\t",$userarray[8]);
		$tplcontent['birthday']="$birthday[0]-$birthday[1]-$birthday[2]";
		
		$tplcontent['website']="<a href=\"$userarray[9]\">$userarray[9]</a>&nbsp";
		
		$tplcontent['icq']="$userarray[10]&nbsp";
		
		$tplcontent['yim']="$userarray[11]&nbsp";
		
		$tplcontent['aim']="$userarray[12]&nbsp";
		
		$tplcontent['msn']="$userarray[13]&nbsp";
		
		$lastpost=date($dateformat,$userarray[18]+$timeoffsetseconds);
		if($userarray[18]){
			$tplcontent['lastpost']="$lastpost";
		}else{
			$tplcontent['lastpost']="never";
		}
		
		$tplcontent['group']="$userarray[15]";
		
		$profilefieldsarray=getdata("$configarray[5]/profilefields.php");
		$userprofilefieldsarray=getdata("$configarray[1]/$user/profilefields.php");
		
		for($n=0;$n<count($profilefieldsarray);$n++){
			
			unset($tplcontent2);
			$tplcontent2['fieldname'].=$profilefieldsarray[$n];
			
			if($userprofilefieldsarray[$n]){
				$tplcontent2['fielddata'].="$userprofilefieldsarray[$n]";
			}else{
				$tplcontent2['fielddata'].="&nbsp";
			}
			
			$tplcontent['extrainfo'].=template('profileextrarow',$tplcontent2);
			
		}
		
		
		if($userloggedinarray[15]=="administrator"){
			$tplcontent['editprofile'].="<a href=\"user_edit.php?user=$user\">Edit this profile</a>";
		}
		
		echo template('profile',$tplcontent);
		
	}
	
}//board closed check

require ("footer.php");
?>
